'use strict';

module.exports = {
    up: async (queryInterface, Sequelize) => {
        const { STRING, INTEGER, DATE, DOUBLE, NOW } = Sequelize;

        await queryInterface.createTable(
            'tbl_user_mate',
            {
                id: {
                    type: INTEGER,
                    primaryKey: true,
                    autoIncrement: true
                },
                user_id: {
                    type: INTEGER,
                    allowNull: false,
                    unique: true
                },
                gender: {
                    type: INTEGER,
                    allowNull: true
                },
                min_age: {
                    type: INTEGER,
                    allowNull: true
                },
                max_age: {
                    type: INTEGER,
                    allowNull: true
                },
                min_height: {
                    type: INTEGER,
                    allowNull: true
                },
                max_height: {
                    type: INTEGER,
                    allowNull: true
                },
                min_weight: {
                    type: INTEGER,
                    allowNull: true
                },
                max_weight: {
                    type: INTEGER,
                    allowNull: true
                },
                stature_id: {
                    type: INTEGER,
                    allowNull: true
                },
                live_region: {
                    type: STRING(32),
                    allowNull: true
                },
                birth_region: {
                    type: STRING(32),
                    allowNull: true
                },
                marriage_state: {
                    type: INTEGER,
                    allowNull: true
                },
                child_state: {
                    type: INTEGER,
                    allowNull: true
                },
                nationality_id: {
                    type: INTEGER,
                    allowNull: true
                },
                month_pay: {
                    type: INTEGER,
                    allowNull: true
                },
                education_id: {
                    type: INTEGER,
                    allowNull: true
                },
                organization_id: {
                    type: INTEGER,
                    allowNull: true
                },
                vocation_id: {
                    type: INTEGER,
                    allowNull: true
                },
                house_state: {
                    type: INTEGER,
                    allowNull: true
                },
                loan_state: {
                    type: INTEGER,
                    allowNull: true
                },
                vehicle_state: {
                    type: INTEGER,
                    allowNull: true
                },
                smoke_state: {
                    type: INTEGER,
                    allowNull: true
                },
                drink_state: {
                    type: INTEGER,
                    allowNull: true
                },
                marriage_plan: {
                    type: INTEGER,
                    allowNull: true
                },
                child_plan: {
                    type: INTEGER,
                    allowNull: true
                },
                created_at: {
                    type: DATE,
                    allowNull: false,
                    defaultValue: NOW
                },
                updated_at: {
                    type: DATE,
                    allowNull: false,
                    defaultValue: NOW
                }
            },
            {
                charset: 'utf8'
            });

        await queryInterface.createTable(
            'tbl_login_record',
            {
                id: {
                    type: INTEGER,
                    primaryKey: true,
                    autoIncrement: true
                },
                type: {
                    type: INTEGER,
                    allowNull: false,
                    defaultValue: 0
                },
                user_id: {
                    type: INTEGER,
                    allowNull: false
                },
                amount: {
                    type: INTEGER,
                    allowNull: false,
                    defaultValue: 1
                },
                longitude: {
                    type: DOUBLE,
                    allowNull: true
                },
                latitude: {
                    type: DOUBLE,
                    allowNull: true
                },
                created_at: {
                    type: DATE,
                    allowNull: false,
                    defaultValue: NOW
                },
                updated_at: {
                    type: DATE,
                    allowNull: false,
                    defaultValue: NOW
                }
            },
            {
                charset: 'utf8'
            });

        await queryInterface.createTable(
            'tbl_look_record',
            {
                id: {
                    type: INTEGER,
                    primaryKey: true,
                    autoIncrement: true
                },
                type: {
                    type: INTEGER,
                    allowNull: false,
                    defaultValue: 0
                },
                user_id: {
                    type: INTEGER,
                    allowNull: false
                },
                target_user_id: {
                    type: INTEGER,
                    allowNull: false
                },
                amount: {
                    type: INTEGER,
                    allowNull: false,
                    defaultValue: 1
                },
                desc: {
                    type: STRING(32),
                    allowNull: true
                },
                created_at: {
                    type: DATE,
                    allowNull: false,
                    defaultValue: NOW
                },
                updated_at: {
                    type: DATE,
                    allowNull: false,
                    defaultValue: NOW
                }
            },
            {
                charset: 'utf8'
            });
    },

    down: async (queryInterface, Sequelize) => {
        // await queryInterface.dropTable('tbl_user_mate');
        // await queryInterface.dropTable('tbl_login_record');
        // await queryInterface.dropTable('tbl_look_record');
    }
};
